package com.zqw.ss;

import java.lang.reflect.Field;

public class Transition {

    public static <T,V> V  transition(T t,Class<V> cls){
        Class<?> aClass = t.getClass();
        Field[] dfs = aClass.getDeclaredFields();
        V v = null;
        MyPa dc;
        Field declaredField = null;
        try {
            v = cls.newInstance();
            for (int i = 0; i < dfs.length; i++) {
                dc = dfs[i].getDeclaredAnnotation(MyPa.class);
                dfs[i].setAccessible(true);
                try {
                    declaredField = cls.getDeclaredField(dc.value());
                    declaredField.setAccessible(true);
                    declaredField.set(v,dfs[i].get(t));
                } catch (Exception e) {
                }
            }
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return v;
    }

}
